<?php
     include_once('../../src/classes/class.mysql.php');
    
     $comtec_id_owner = $_POST['comtec_id_owner'];
     $token = $_POST['token']; 
     
     //TODO validar el token recibido por POST y el de la sesion.
     
     $db = new MySQL();  
     $tsql = "UPDATE owner SET status_reg=0 WHERE 
              comtec_id_owner=".$comtec_id_owner;
     if($db->query($tsql))
     {
      $tsql = "SELECT comtec_id_user FROM owner WHERE comtec_id_owner=".$comtec_id_owner;
      $result= $db->fetch_array($db->query($tsql));
      $comtec_id_user = $result['comtec_id_user'];
      $tsql = "UPDATE users SET status_reg=0 WHERE
               comtec_id_user=".$comtec_id_user;
      
      if ($db->query($tsql)){
       echo "<script>loadOwners();</script>";
       //echo "<script>alert('Se ha eliminado el propietario exitosamente');</script>";
      }
      
     } 
     else
     {
      echo '<p class="error">';
      echo "Error al eliminar el due&ntilde;o \n";  
      echo '</p';              
     }
?>
